package com.example.file.utils;

import lombok.extern.slf4j.Slf4j;

/**
 * 文件工具类
 *
 * @Author wxy
 * @Date 2020/11/18 13:48
 * @Version 1.0
 */
@Slf4j
public final class FileUtils {

    /**
     * minIo文件夹策略设置可读公开
     */
    public static String policy(String bucketName) {
        return String.format(
                "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"s3:GetBucketLocation\",\"s3:ListBucket\"],\"Resource\":[\"arn:aws:s3:::%s\"]},{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"s3:GetObject\"],\"Resource\":[\"arn:aws:s3:::%s/*\"]}]}",
                bucketName,
                bucketName);
    }
}
